package com.service.business.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.service.business.product.controller.rep.ProductCategoryRep;
import com.service.business.product.service.ProductCategoryService;
import com.service.business.support.Language;
import com.service.business.utils.LanguageUtil;
import com.service.dao.enums.CommonStatusEnums;
import com.service.dao.model.ProductCategory;
import com.service.utility.modelmapper.ModelMapperUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.service.dao.mapper.ProductCategoryMapper;


@Service("productCategoryService")
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements ProductCategoryService {

    @Override
    public List<ProductCategoryRep> listAll() {
        return list(new LambdaQueryWrapper<ProductCategory>()
                .eq(ProductCategory::getLanguage, Language.LANG.get())
                .eq(ProductCategory::getCategoryStatus, CommonStatusEnums.ACTIVE.getCode())).stream()
                .map(item -> ModelMapperUtil.map(item, ProductCategoryRep.class))
                .collect(Collectors.toList());
    }
}
